<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			textarea {
				width: 90%;
				height: 30vh;
			}
		</style>
	</head>
	<body>
		<textarea > </textarea>
		<button type="button" onclick="create()">生成</button>
		<div id="render">
			
		</div>
		<script type="text/javascript">
			// document.write(strs)

			function create() {
				console.log('', document.querySelector('textarea'))
				let str = document.querySelector('textarea').value
				const result = []
				let arr = []
				let demo = 'varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT'
				let SqlStr = ''

				str = str.replace(/\s*/g, '')
				str = str.replace(/(?!\_)(?<!\_)\b/g, ',')

				let flag = 0
				let adStr = ''

				const atr = str.split(',')

				for (let i = 0; i < atr.length; i++) {
					arr.push(atr[i])
					if (arr.length === 1) {} else {
						result.push(arr)
						arr = []
					}
				}

				// CZZMZYSXM varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '主治麻醉医师',
				const maps = new Map(result)
				let strs = ''
				for (let [comment, key] of maps) {
					if (strs) strs += `,<br/>`
					strs +=
						`${key} varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '${comment}'`
				}
				document.querySelector('#render').innerHTML = strs
				
			}
		</script>
	</body>
</html>
